package org.xingyun.web;

import org.xingyun.service.AreaService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet(value = "/area", name = "areaServlet")
public class AreaServlet extends javax.servlet.http.HttpServlet {
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        try {
            System.out.println("查询区域的请求来了");
            response.setContentType("text/json;charset=utf-8");
            String cityid = request.getParameter("cityid");
            System.out.println(cityid);
            String str = new AreaService().findAllArea(cityid);
            response.getWriter().write(str);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
